from datetime import datetime
from typing import List, Union

from fastapi.params import Query
from pydantic import BaseModel, Field

from forward.utils.tools import ToolsUtil


class DecoratePageSaveInSchema(BaseModel):
    id: int = Query(gt=0)  # type: ignore
    page_type: int = Query()  # type: ignore
    page_data: str = Query()  # type: ignore
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class DecoratePageDetailOutSchema(BaseModel):
    id: int
    page_type: int
    page_data: str


class DecorateDataArticleInSchema(BaseModel):
    limit: int = Query(default=10)  # type: ignore


class DecorateTabbarStyleSchema(BaseModel):
    defaultColor: str | None
    selectedColor: str | None


class DecorateTabbarListInSchema(BaseModel):
    name: Union[str, None] = Field(default=None)
    selected: Union[str, None] = Field(default=None)
    unselected: Union[str, None] = Field(default=None)
    link: Union[str, None] = Field(default=None)


class DecorateTabbarListSchema(BaseModel):
    id: int
    name: str
    selected: str
    unselected: str
    link: str
    created_time: datetime | None = Field(None)  # 创建时间
    updated_time: datetime | None = Field(None)  # 更新时间


class DecorateTabbarOutSchema(BaseModel):
    style: DecorateTabbarStyleSchema
    list: List[DecorateTabbarListSchema]


class DecorateTabbarSaveInSchema(BaseModel):
    style: DecorateTabbarStyleSchema
    list: List[DecorateTabbarListInSchema]
